package org.emavaj.sanguosha.model.card.equipment.weapon;


import org.emavaj.sanguosha.model.card.AbstractCard;
import org.emavaj.sanguosha.model.card.equipment.AbstractEquipmentCard;
import org.emavaj.sanguosha.model.exception.SGSException;
import org.emavaj.sanguosha.model.vo.CardVO;
import org.w3c.dom.NamedNodeMap;

/**
 * User: DIZEM Time: 11-4-1 下午10:51
 * 
 * eMavaj updated 20120916
 */
public abstract class AbstractWeaponCard extends AbstractEquipmentCard {
	/**
	 * Attack distance
	 */
	private int weaponRange;
	private boolean selectable;

	@Override
	public void init(NamedNodeMap typeMap, NamedNodeMap map) {
		super.init(typeMap, map);
		this.weaponRange = Integer.parseInt(typeMap.getNamedItem("range")
				.getNodeValue());
		this.selectable = Boolean.parseBoolean(typeMap.getNamedItem(
				"selectable").getNodeValue());
	}

	public int getWeaponRange() {
		return weaponRange;
	}

	public boolean isSelectable() {
		return this.selectable;
	}
	
	@Override
	public void fromCardVO(CardVO cardVO) {
		super.fromCardVO(cardVO);
		this.weaponRange = cardVO.getWeaponRange();
		this.selectable = cardVO.isSelectable();
	}

	@Override
	public int getEquipmentType() {
		return AbstractEquipmentCard.TYPE_WEAPON_CARD;
	}

	@Override
	public boolean needsFeedBack() {
		return false;
	}

	@Override
	public boolean isFeedBackWork(AbstractCard card) {
		throw new SGSException("不需要反馈的卡牌被期望反馈");
	}
}
